home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / SAT / myPlatform ƒ / myPlatform.p < prev    next >
Encoding:
Text File  |  1994-07-26  |  2.4 KB  |  88 lines  |  [TEXT/PJMM]

  1. {***************************}
  2. {********* myPlatform **********}
  3. {***************************}
  4.  
  5. {This demo is a hack I made, testing if we can use faceless sprites to make stationary}
  6. {obstacles. That worked pretty nicely, so I went on and made some moving platforms too.}
  7. {Take it for what it is: a test hack that suggests one way to make this kind of games.}
  8. {There are many other ways. The controls can be improved a lot, but it is a start.}
  9.  
  10. program myPlatform;
  11.  
  12.     uses
  13.         SAT, sPlayerSprite, sPlatform, sMovPlatForm, sHMovPlatForm;
  14.  
  15.     var
  16. {gameWind: WindowPtr;}
  17.         ignoreSp: SpritePtr;
  18.         l: longint;
  19.         p: Point;
  20.     var
  21.         thepat: SATPatHandle;
  22.  
  23.     procedure DrawInfo;
  24.         var
  25.             r: Rect;
  26.     begin
  27.         SetPort(gSAT.backScreen);
  28.         SetRect(r, 100, 50, 300, 100);
  29.         EraseRect(r);
  30.         FrameRect(r);
  31.         MoveTo(110, 70);
  32.         DrawString('SAT Platform demo');
  33.         MoveTo(110, 90);
  34.         DrawString('Move with "," "." and space');
  35.         SATBackChanged(r);
  36.     end;
  37.  
  38. begin
  39. {Standard Inits are done by Think Pascal.}
  40.  
  41.     ConfigureSAT(true, kLayerSort, kBackwardCollision, 32);
  42.     InitSAT(0, 0, 512, 322); {No PICTs}
  43.  
  44. {Use a background pattern (instead of PICTs - just to demo that too)}
  45.     SetPort(gSAT.backScreen);
  46.     thepat := SATGetPat(128);
  47.     SATPenPat(thepat);
  48.     PaintRect(0, 0, gSAT.offsizeV, gSAT.offsizeH);
  49. {The following CopyBits would have been faster if we had used SATSetPortBackScreen}
  50.     CopyBits(gSAT.backScreen^.portBits, gSAT.offScreen^.portBits, gSAT.offScreen^.portrect, gSAT.offscreen^.portrect, srcCopy, nil);
  51.  
  52.     DrawInfo;
  53.  
  54. {Initialize all sprite units}
  55.     initPlayerSprite;
  56.     initPlatform;
  57.     initMovPlatform;
  58.     initHMovPlatform;
  59.  
  60. {Show the game window (SATwind) and update it.}
  61.     ShowWindow(gSAT.wind);
  62.     SelectWindow(gSAT.wind);
  63.     PeekOffscreen;
  64.  
  65. {Make the sprites.}
  66.     GetMouse(p);
  67.     ignoreSp := NewSprite(1, p.h, p.v, @SetupPlayerSprite);
  68.     ignoreSp := NewSprite(0, 50, 300, @SetupPlatform);
  69.     ignoreSp := NewSprite(0, 150, 200, @SetupPlatform);
  70.     ignoreSp := NewSprite(0, 250, 100, @SetupPlatform);
  71.     ignoreSp := NewSprite(0, 350, 50, @SetupPlatform);
  72.  
  73.     ignoreSp := NewSprite(0, 350, 300, @SetupMovPlatform);
  74.     ignoreSp := NewSprite(0, 50, 200, @SetupMovPlatform);
  75.  
  76.     ignoreSp := NewSprite(0, 200, 150, @SetupHMovPlatform);
  77.  
  78.     HideCursor;
  79.     done := false;
  80.     repeat
  81.         l := TickCount;
  82.         RunSAT(true); {Run one frame of animation.}
  83.         while l > TickCount - 2 do {Maximize speed to 30 fps}
  84.             ;
  85.     until done or Button;
  86.     ShowCursor;
  87.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  88. end.